<?php
namespace API\Controller;
use Think\Controller;
class MessageController extends CommonController {
	//用户发送提醒发货的信息
	// true表示载入成功 false失败
	//标识码 0表示失败 1表示成功
	public function Promptshipment(){
		$Message = M('Message');
		$orderid = I("post.orderid");
		//查询是否已提醒过发货
		$action=$Message->where("orderid={$orderid}")->getField("action",true);
		foreach ($action as $key=>$value) {
			if ($action[$key] =="提醒发货" ) {
				$this->response("提醒发货",false,0,"你已经提醒过发货");	
			}
		}
		//没有提醒则发送信息提醒发货
		$data = array(
			"orderid"=>$orderid,
			"action"=>"提醒发货",
			"sendtime"=>time()
		);
		$res=$Message->add($data);
		if (!$res) {
		             $this->response("提醒发货",false,0,"提醒发货失败");	
		}else{
			$this->response("提醒发货",true,1,"提醒发货成功");
		}
	}

	//用户发送确认收货信息
	public function Confirmreceipt(){
		$Message = M('Message');
		$orderid = I("post.orderid");
		$Order = M("Orderlist");
		$data = array(
			"status" => 2
		);
		$Order->where("id ={$orderid}")->save($data);
		
		//发送信息确认收货
		$data = array(
			"orderid"=>$orderid,
			"action"=>"确认收货",
			"sendtime"=>time()
		);
		$res=$Message->add($data);
		if (!$res) {
		             $this->response("确认收货",false,0,"确认收货失败");	
		}else{
			$this->response("确认收货",true,1,"确认收货成功");
		}
	}

	//用户删除订单
	public function Delorder(){
		$orderid = I("post.orderid");
		$Order = M("Orderlist");
		$data = array(
			"status" => 3
		);
		$res=$Order->where("id ={$orderid}")->save($data);
		if (!$res) {
		             $this->response("删除订单",false,0,"删除订单失败");	
		}else{
			$this->response("删除订单",true,1,"删除订单成功");
		}
	}
	
}